package ch3;

public class OjbectArray {

	public static void main(String[] args) {
		Student[] ar = new Student[20];
		// !!!!给数组的第一个位置放入一个对象
		for (int i = 0; i < ar.length; i++) {
			ar[i] = new Student();
		}
		ar[0].name = "赵华强";
		ar[0].ch = 99;
		ar[0].math = 88;
		System.out.println("输出对象数组：");
		for (int i = 0; i < ar.length; i++) {
			// System.out.println(ar[i]);
			ar[i].show();
		}
		Student[] s2 = { new Student(), new Student(), new Student() };
		s2[0].name = "wangxiang";
		s2[0].ch = 88;
		s2[0].math = 89;
		s2[1].name = "谢旭";
		s2[1].ch = 95;
		s2[1].math = 96;
		s2[2].name = "丁鹏飞";
		s2[2].ch = 80;
		s2[2].math = 81;
		for (int i = 0; i < s2.length; i++) {
			s2[i].show();
		}
		Calculator c = new Calculator();
		int avg = c.calcAvg3(s2);
		System.out.println("3位同学的平均分是：" + avg);
	}

}
